package com.ygqh.baby.controller.mobile;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ygqh.baby.ao.Message;
import com.ygqh.baby.ao.ResponseEntity;
import com.ygqh.baby.po.YgUserIdentity;
import com.ygqh.baby.service.YgUserIdentityService;
import com.ygqh.baby.utils.SessionUtil;
import com.ygqh.baby.utils.UmPushApi;

@Controller()
@RequestMapping("/app/push")
public class PushMessageController extends BaseController {
	protected Logger logger = Logger.getLogger(this.getClass());

	@RequestMapping(value = "/sendMessge")
	@ResponseBody
	public ResponseEntity sendMessge(String appType, String apptoken, String msg) {

		Map<String, String> map = new HashMap<>();
		map.put("key", "userMessage");
		if (appType.equals("Android")) {
			UmPushApi.sendAndroidAotificationByAlias(apptoken, "token", null,
					"消息通知", msg, null, map);
		} else {
			UmPushApi.sendIOSByAlias(apptoken,
					"token", 1, "消息通知", null, msg, map);
		}
		return ResponseEntity.success();
	}

	@RequestMapping(value = "/sendOnLineNotice")
	@ResponseBody
	public ResponseEntity sendOnLineNotice(String appType, String apptoken,String msg) {
		Map<String, String> map = new HashMap<>();
		map.put("key", "userMessage");
		if (appType.equals("Android")) {
			UmPushApi.sendAndroidAotificationByAlias(apptoken, "token", null,
					"上线通知", msg, null, map);
		} else {
			UmPushApi.sendIOSByAlias(apptoken,
					"token", 1, "上线通知", null, msg, map);
		}
		return ResponseEntity.success();
	}
}
